<SCRIPT language="JavaScript">

var min
var sec
var ShowReadingAgain = ''
var platform = 'win'
if (navigator.appVersion.indexOf('Mac') != -1) {platform = 'mac'}

macrightchar = ':-)'
macwrongchar = 'X'
winrightchar = ':-)'
winwrongchar = 'X'


DoneStatus = new Array();
DoneStatus[1] = '0';


Responses = new Array();
Responses[1] = 'Muy bien. Sigue jugando.';
Responses[2] = 'Lo siento. Te quedas en la casilla. Tira el siguiente jugador';
Responses[3] = 'Lo siento. No avanzas. Juega el siguiente.';


IndicatorName = new Array();
IndicatorName[1] = 'document.QuizForm.Q1A';
IndicatorName[2] = 'document.QuizForm.Q1B';
IndicatorName[3] = 'document.QuizForm.Q1C';


var Score = 0;
var Tries = 0;
var Percent = 0;
var YourScore = '';
var DefaultRight = 'Correcto. sigue jugando';
var DefaultWrong = 'Lo siento, pierdes turno';

if (platform == 'mac') {
	rightchar = unescape(macrightchar)
	wrongchar = unescape(macwrongchar)
}
else {
	rightchar = unescape(winrightchar)
	wrongchar = unescape(winwrongchar)
}

function DownTime(mm,ss){
min=mm
sec=ss
if (sec==0) {
     sec = 60
     min--
}
 sec--
if (sec<10){
      sec="0" + sec
}
parent.Timer.document.TimerForm.face.value= min+":"+sec
if ((min==0) && (sec==0)){
TimesUp()
}
else{
        setTimeout('DownTime(min,sec)',1000)
}
}

function SetUp(){
if (parent.Timer != null) {
Stuff='<HTML><BODY BGCOLOR="#FFFFFF" BACKGROUND=""><CENTER><FORM NAME="TimerForm"><INPUT TYPE="Button"';
Stuff+=' NAME="StartIt" VALUE="" onClick="parent.Code.StartReading()"></FORM></CENTER></BODY></HTML>';
WriteToReading('');
WriteToTimer(Stuff);
}
}

function StartReading(){
Stuff='<HTML><BODY TEXT="#BA050A" BGCOLOR="FFFFFF" BACKGROUND=""><CENTER><FORM NAME="TimerForm" onSubmit="return false">';
Stuff+='<B></B> <INPUT TYPE=text NAME="face" SIZE=6 VALUE="1:00"></FORM></CENTER></BODY></HTML>';
WriteToTimer(Stuff);
parent.Reading.location.href='p1r.htm';
timeoutID=setTimeout('DownTime(1,0)',1000);
}

function TimesUp() {
if (ShowReadingAgain.length > 0) {
Stuff='<HTML><BODY BGCOLOR="FFFFFF" BACKGROUND=""><CENTER><FORM NAME="TimerForm">';
Stuff+='<INPUT TYPE="Hidden" NAME="ThisAvoidsNavigator3Bug">';
Stuff+='<INPUT TYPE="Button" NAME="StartIt" VALUE="" onClick="parent.Code.StartReading()">';
Stuff+='</FORM></CENTER></BODY></HTML>';
WriteToTimer(Stuff);
}
WriteToReading('');
}

function WriteToReading(Stuff){
parent.Reading.document.clear();
parent.Reading.document.open();
parent.Reading.document.writeln ("<html><body bgcolor=#FFFFFF text=#BA050A BACKGROUND=\"\">");
parent.Reading.document.writeln ("<font size=+1>");
parent.Reading.document.writeln ("<center><b>");
parent.Reading.document.writeln (Stuff);
parent.Reading.document.writeln ("</b></center></font></body></html>");
parent.Reading.document.close();
}

function WriteToTimer(Stuff){
parent.Timer.document.clear();
parent.Timer.document.open();
parent.Timer.document.writeln (Stuff);
parent.Timer.document.close();
}

function CheckAnswer(QNum, AnsNum, Correct) {
whichfb = (5*(QNum-1) + AnsNum)

 if (Correct == 1) {
	if (DoneStatus[QNum] != '1'){
		Tries = Tries + 1;
		DoneStatus[QNum] = '1';
		Score = Score + 1;}
	if (eval(IndicatorName[whichfb]) != null){
		eval(IndicatorName[whichfb]).value = rightchar}
	Feedback = Responses[whichfb]
	if (Feedback == '') {Feedback = DefaultRight}
	Percent = Math.floor(Score*100/Tries) + '%';
	Feedback = Feedback + '<BR>' + YourScore + ' ' + Percent + '.';

	var i = 0;
	var AllDone = true;
	for (i=1; i<DoneStatus.length; i++){
		if (DoneStatus[i] == '0'){
			AllDone = false;
		}
	}
	if (AllDone == true){
		Feedback += '<BR>';
	}

	WriteFeedback(Feedback);
	}

 else {
	if (DoneStatus[QNum] != '1'){
		Tries = Tries + 1;}
	if (eval(IndicatorName[whichfb]) != null){
		eval(IndicatorName[whichfb]).value = wrongchar}
	Feedback = Responses[whichfb]
	if (Feedback == '') {Feedback = DefaultWrong}
	WriteFeedback(Feedback)
 }
}

function WriteFeedback(Feedback) {
  parent.FeedbackFrame.document.clear();
  parent.FeedbackFrame.document.open();
  parent.FeedbackFrame.document.writeln("<html>");
  parent.FeedbackFrame.document.writeln("<body bgcolor=#FFFFFF text=#BA050A BACKGROUND=\"\">");
  parent.FeedbackFrame.document.writeln("<font size = +1><center><b>");
  parent.FeedbackFrame.document.writeln(Feedback);
  parent.FeedbackFrame.document.writeln("</b></center></font></body></html>");
  parent.FeedbackFrame.document.close();
}

</SCRIPT>